<div class="nav_bar">
    <div class="top1">
        <div class="nav-bar">
            <div class="nav-left">
                    {{bus_info.info.title}}
            </div>
            <div class="nav-right">
                <div class="nav-box {{Private}}">
                    <a href="tags.html" class="nav-button first">商品分类</a>
                    <a href="all-goods-beta.html#?id=3" class="nav-button ">新品上市</a>
                    <a href="store-int.html" class="nav-button ">店铺介绍</a>
                    <a href="help.html" class="nav-button ">省钱攻略</a>
                </div>
                <div event-mouseleave="{{'$Event.search_can_blur'}}" event-mouseenter="{{'$Event.search_no_blur'}}" class="search-box {{Private}}">
                    <a class="nav-button icon-search" event-click="{{'$Event.show_search_box'}}" title="搜索"></a>
                    <input ele-focus="{{'$Boolean:'+$Cache.search_input.focus}}" focus="{{$Cache.focus}}" event-keyup="{{'$Event.enter_href'}}" type="text" class="search-input" bind-input="{{'$Cache.search_text'}}" placeholder='请输入搜索内容' event-blur="{{'$Event.close_search_box'}}" />
                    <a target="_blank" href="searchset.html?q={{$Cache.search_text}}" class="icon-arrow-right" title="搜索" event-click="{{'$Event.href'}}"></a>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/vm">
function (vm) {
    require(['common','jQuery'],function(jSouper,$){
        //是否可关闭搜索栏
        var _search_can_blur_able = false;
        App.set("$Event.search_can_blur",function () {
            _search_can_blur_able = true;
        });
        App.set("$Event.search_no_blur",function () {
            _search_can_blur_able = false;
        });
        App.set('$Event.show_search_box',function(){
            App.set('Private','focus');
            App.set("$Cache.search_input.focus",true);
            App.set("$Cache.event_name","$Event.test");
        });
        App.set('$Event.close_search_box',function(){
            App.set("$Cache.search_input.focus",false);
            if (_search_can_blur_able) {
                App.set('Private','');
            }else{
                App.set("$Cache.search_input.focus",true);
            }
        });
        App.set('$Event.href',function(){
            App.set('Private','focus');
            var search_text = App.get('$Cache.search_text');
            search_text = jSouper.trim(search_text);
            if(!search_text){
                alert('warn','请输入搜索内容');
                return false;
            }
        });
        App.set('$Event.enter_href',function(e){
            var search_text = App.get('$Cache.search_text');
            search_text = jSouper.trim(search_text);
            if(e.which==13){
                if (search_text) {
                    window.open("http://dev.dotnar.com:2222/searchset.html?q="+search_text);
                }else{
                    alert('warn','请输入搜索内容');
                }
            }

        });
    })
}
</script>